package com.mao.jxc.admin;

import com.mao.jxc.admin.exceptions.ParamsException;
import com.mao.jxc.admin.model.RespBean;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author: Administrator
 * @description: 全局异常处理类
 * @cteate 2021-07-21-22:14
 */
@ControllerAdvice
public class GlobalExpectionHandler {

    @ExceptionHandler(ParamsException.class)
    @ResponseBody
    public RespBean paramsExceptionHandler(ParamsException e){
        return RespBean.error(e.getMsg());

    }
    @ExceptionHandler(Exception.class)
    @ResponseBody
    public RespBean paramsExceptionHandler(Exception e){
        return RespBean.error(e.getMessage());

    }
}
